package com.LachesismStorm.lachesism.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * lachesism
 *
 * @Date:
 */
@Configuration
public class FileHandleConfig extends WebMvcConfigurationSupport {

    @Value("${file.tyre.address}")
    private String imageAddress;
    @Value("${file.video.address}")
    private String videoAddress;

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        //映射static路径的请求到static目录下
        // 静态资源访问路径和存放路径配置
        //registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        // swagger访问配置
        registry.addResourceHandler("/swagger-ui/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
                .resourceChain(false);
//      registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/", "classpath:/META-INF/resources/webjars/");
        //通过image访问本地的图片
        registry.addResourceHandler("/image/**").addResourceLocations("file:" + imageAddress);
        registry.addResourceHandler("/video/**").addResourceLocations("file:" + videoAddress);
    }
}
